home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 28.5 KB | 870 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Commands.cpp
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "Container.hpp"
-
- #ifndef COMMANDS_H
- #include "Commands.h"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k"
- #endif
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef SELECT_H
- #include "Select.h"
- #endif
-
- #ifndef PROXY_H
- #include "Proxy.h"
- #endif
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWFCTCLP_H
- #include "FWFctClp.h"
- #endif
-
- #ifndef FWMEMMGR_H
- #include "FWMemMgr.h"
- #endif
-
- #ifndef FWSOMENV_H
- #include "FWSOMEnv.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- //========================================================================================
- // Runtime Information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfcontainer
- #endif
-
- FW_DEFINE_AUTO(CClipboardCommand)
- FW_DEFINE_AUTO(CDragCommand)
- FW_DEFINE_AUTO(CDropCommand)
- FW_DEFINE_AUTO(CInsertCommand)
- FW_DEFINE_AUTO(CResizeCommand)
- FW_DEFINE_AUTO(CViewAsCommand)
- FW_DEFINE_AUTO(CSetBackgroundColorCommand)
-
- //========================================================================================
- // CClipboardCommand
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CClipboardCommand constructor
- //----------------------------------------------------------------------------------------
-
- CClipboardCommand::CClipboardCommand(Environment* ev,
- ODCommandID commandID,
- CContainerPart* part,
- CContainerFrame* frame,
- CContainerSelection* selection,
- FW_Boolean canUndo) :
- FW_CClipboardCommand(ev, commandID, frame, canUndo),
- fContainerPart(part),
- fContainerSelection(selection),
- fUndoContent(NULL)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CClipboardCommand destructor
- //----------------------------------------------------------------------------------------
-
- CClipboardCommand::~CClipboardCommand()
- {
- delete fUndoContent;
- }
-
- //----------------------------------------------------------------------------------------
- // CClipboardCommand::SaveUndoState
- //----------------------------------------------------------------------------------------
- void CClipboardCommand::SaveUndoState(Environment* ev) // Override
- {
- ODCommandID commandID = GetCommandID(ev);
-
- if (commandID == kODCommandCut || commandID == kODCommandClear)
- {
- FW_ASSERT(fUndoContent == NULL);
- fUndoContent = FW_NEW(CUndoContent, (ev, fContainerSelection));
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CClipboardCommand::SaveRedoState
- //----------------------------------------------------------------------------------------
- void CClipboardCommand::SaveRedoState(Environment* ev) // Override
- {
- if (GetCommandID(ev) == kODCommandPaste)
- {
- FW_ASSERT(fUndoContent == NULL);
- fUndoContent = FW_NEW(CUndoContent, (ev, fContainerSelection));
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CClipboardCommand::FreeUndoState
- //----------------------------------------------------------------------------------------
- void CClipboardCommand::FreeUndoState(Environment* ev) // Override
- {
- ODCommandID commandID = GetCommandID(ev);
-
- if (commandID == kODCommandCut || commandID == kODCommandClear)
- fUndoContent->DeleteSavedProxies(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CClipboardCommand::FreeRedoState
- //----------------------------------------------------------------------------------------
- void CClipboardCommand::FreeRedoState(Environment* ev) // Override
- {
- if (GetCommandID(ev) == kODCommandPaste)
- fUndoContent->DeleteSavedProxies(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CClipboardCommand::UndoIt
- //----------------------------------------------------------------------------------------
- void CClipboardCommand::UndoIt(Environment* ev) // Override
- {
- FW_CClipboardCommand::UndoIt(ev); // call inherited
-
- switch (GetCommandID(ev))
- {
- case kODCommandCut:
- case kODCommandClear:
- fUndoContent->RestoreProxySelection(ev);
- break;
-
- case kODCommandPaste:
- fUndoContent->RemoveProxySelection(ev);
- break;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CClipboardCommand::RedoIt
- //----------------------------------------------------------------------------------------
- void CClipboardCommand::RedoIt(Environment* ev) // Override
- {
- FW_CClipboardCommand::RedoIt(ev); // call inherited
-
- switch (GetCommandID(ev))
- {
- case kODCommandCut:
- case kODCommandClear:
- fUndoContent->RemoveProxySelection(ev);
- break;
-
- case kODCommandPaste:
- fUndoContent->RestoreProxySelection(ev);
- break;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CClipboardCommand::PreCommand
- //----------------------------------------------------------------------------------------
-
- void CClipboardCommand::PreCommand(Environment* ev)
- {
- if (GetCommandID(ev) == kODCommandPaste)
- fContainerSelection->CloseSelection(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CClipboardCommand::CommandDone
- //----------------------------------------------------------------------------------------
-
- void CClipboardCommand::CommandDone(Environment* ev)
- {
- if (GetCommandID(ev) == kODCommandPaste)
- fContainerSelection->CenterSelection(ev, GetFrame(ev));
- }
-
- //========================================================================================
- // class CDragCommand
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CDragCommand constructor
- //----------------------------------------------------------------------------------------
- CDragCommand::CDragCommand(Environment* ev,
- CContainerPart* part,
- FW_CFrame* frame,
- CContainerSelection* selection,
- FW_Boolean canUndo)
- : FW_CDragCommand(ev, frame, canUndo),
- fContainerPart(part),
- fContainerSelection(selection),
- fDraggedContent(NULL)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CDragCommand destructor
- //----------------------------------------------------------------------------------------
-
- CDragCommand::~CDragCommand()
- {
- delete fDraggedContent; // Will call remove all if necessary
- fDraggedContent = NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // CDragCommand::SaveUndoState
- //----------------------------------------------------------------------------------------
-
- void CDragCommand::SaveUndoState(Environment* ev) // Override
- {
- FW_ASSERT(fDraggedContent == NULL);
- fDraggedContent = FW_NEW(CUndoContent, (ev, fContainerSelection));
- }
-
- //----------------------------------------------------------------------------------------
- // CDragCommand::UndoIt
- //----------------------------------------------------------------------------------------
-
- void CDragCommand::UndoIt(Environment* ev) // Override
- {
- // ----- Add the dragged proxies back into the part
- CContentProxyIterator ite(fDraggedContent);
- for (CProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
- {
- fContainerPart->AttachProxy(ev, proxy);
- }
-
- // ----- Add the saved proxies to the selection
- fContainerSelection->SelectContent(ev, fDraggedContent);
-
- // ----- Invalidate
- GetPresentation(ev)->Invalidate(ev, fContainerSelection->GetUpdateShape(ev));
- }
-
- //----------------------------------------------------------------------------------------
- // CDragCommand::RedoIt
- //----------------------------------------------------------------------------------------
-
- void CDragCommand::RedoIt(Environment* ev) // Override
- {
- // Select saved proxies
- fContainerSelection->SelectContent(ev, fDraggedContent);
-
- fContainerSelection->ClearSelection(ev); // clear them, again
- }
-
- //----------------------------------------------------------------------------------------
- // CDragCommand::FreeUndoState
- //----------------------------------------------------------------------------------------
-
- void CDragCommand::FreeUndoState(Environment* ev) // Override
- {
- // Delete the dragged proxies - they're gone forever
- fDraggedContent->DeleteSavedProxies(ev);
- }
-
- //========================================================================================
- // class CDropCommand
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CDropCommand constructor
- //----------------------------------------------------------------------------------------
- CDropCommand::CDropCommand(Environment* ev,
- CContainerPart* part,
- FW_CFrame* frame,
- ODDragItemIterator* dropInfo,
- ODFacet* facet,
- const FW_CPoint& dropPoint,
- FW_Boolean canUndo)
- : FW_CDropCommand(ev, frame, dropInfo, facet, dropPoint, canUndo),
- fContainerPart(part),
- fDropDelta(FW_kZeroPoint),
- fDroppedContent(NULL),
- fContainerSelection((CContainerSelection*)frame->GetPresentation(ev)->GetSelection(ev))
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CDropCommand destructor
- //----------------------------------------------------------------------------------------
-
- CDropCommand::~CDropCommand()
- {
- delete fDroppedContent;
- }
-
- //----------------------------------------------------------------------------------------
- // CDropCommand::DoDrop
- //----------------------------------------------------------------------------------------
- FW_Boolean CDropCommand::DoDrop(Environment* ev,
- ODStorageUnit* dropSU,
- const FW_CPoint& mouseDownOffset,
- const FW_CPoint& dropPoint,
- FW_Boolean isDropMove,
- short itemNumber)
- {
- if (itemNumber == 1)
- fContainerSelection->CloseSelection(ev);
-
- FW_Boolean result = FW_CDropCommand::DoDrop(ev, dropSU, mouseDownOffset, dropPoint, isDropMove, itemNumber);
-
- if (result)
- {
- fContainerSelection->CalcCache(ev);
-
- FW_CPoint newPosition(dropPoint.x - mouseDownOffset.x, dropPoint.y - mouseDownOffset.y);
-
- FW_CRect box = fContainerSelection->GetDragRect(ev);
-
- fContainerSelection->OffsetSelection(ev, newPosition.x - box.left, newPosition.y - box.top);
-
- ODShape* updateShape = fContainerSelection->GetUpdateShape(ev);
-
- // ----- Calculate clip -----
- FW_CFacetClipper facetClipper;
- facetClipper.Clip(ev, fContainerSelection->GetPresentation(ev), updateShape);
-
- // ----- Invalidate -----
- GetPresentation(ev)->Invalidate(ev, updateShape);
-
- // ----- If I am not the active part I should not have a selection -----
- if (!fContainerPart->HasSelectionFocus(ev))
- fContainerSelection->CloseSelection(ev);
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // CDropCommand::DoDroppedInSameFrame
- //----------------------------------------------------------------------------------------
- FW_Boolean CDropCommand::DoDroppedInSameFrame(Environment* ev,
- ODStorageUnit* dropSU,
- const FW_CPoint& mouseDownOffset,
- const FW_CPoint& dropPoint)
- {
- FW_UNUSED(dropSU);
-
- FW_CPoint newPosition(dropPoint.x - mouseDownOffset.x, dropPoint.y - mouseDownOffset.y);
-
- FW_CRect box = fContainerSelection->GetDragRect(ev);
-
- fDropDelta = newPosition - box.TopLeft();
- this->OffsetSelection(ev, fDropDelta);
-
- return TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // CDropCommand::SaveRedoState
- //----------------------------------------------------------------------------------------
-
- void CDropCommand::SaveRedoState(Environment* ev) // Override
- {
- // Save proxies that were just dropped
- FW_ASSERT(fDroppedContent == NULL);
- fDroppedContent = FW_NEW(CUndoContent, (ev, fContainerSelection));
- }
-
- //----------------------------------------------------------------------------------------
- // CDropCommand::UndoIt
- //----------------------------------------------------------------------------------------
- void CDropCommand::UndoIt(Environment* ev) // Override
- {
- if (this->IsDragMoveInSameFrame(ev)) // it's a drag-move
- {
- // select dropped proxies and move them back to the original position
- fContainerSelection->SelectContent(ev, fDroppedContent);
- this->OffsetSelection(ev, -fDropDelta);
- fContainerSelection->SelectionChanged(ev); // need more than this for redraw???
- }
- else
- {
- // select dropped proxies and remove them from the document
- fContainerSelection->SelectContent(ev, fDroppedContent);
- fContainerSelection->ClearSelection(ev);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDropCommand::RedoIt
- //----------------------------------------------------------------------------------------
- void CDropCommand::RedoIt(Environment* ev) // Override
- {
- if (this->IsDragMoveInSameFrame(ev)) // it's a drag-move
- {
- // select dropped proxies and move them to new position
- fContainerSelection->SelectContent(ev, fDroppedContent);
- this->OffsetSelection(ev, fDropDelta);
- }
- else // dropped proxies are copies
- {
- // add dropped proxies back into document
- this->RestoreDroppedProxies(ev);
- GetPresentation(ev)->Invalidate(ev, fContainerSelection->GetUpdateShape(ev));
- }
- fContainerSelection->SelectionChanged(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CDropCommand::RestoreDroppedProxies
- //----------------------------------------------------------------------------------------
-
- void CDropCommand::RestoreDroppedProxies(Environment* ev)
- {
- // Add the dropped proxies back into the part
- CContentProxyIterator ite(fDroppedContent);
- for (CProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
- {
- fContainerPart->AttachProxy(ev, proxy);
- }
-
- // Add the saved proxies to the selection
- fContainerSelection->SelectContent(ev, fDroppedContent);
- }
-
- //----------------------------------------------------------------------------------------
- // CDropCommand::OffsetSelection
- //----------------------------------------------------------------------------------------
-
- void CDropCommand::OffsetSelection(Environment* ev, const FW_CPoint& delta)
- {
- if (delta != FW_kZeroPoint)
- {
- GetPresentation(ev)->Invalidate(ev, fContainerSelection->GetUpdateShape(ev));
- fContainerSelection->OffsetSelection(ev, delta.x, delta.y);
- GetPresentation(ev)->Invalidate(ev, fContainerSelection->GetUpdateShape(ev));
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CDropCommand::FreeRedoState
- //----------------------------------------------------------------------------------------
- void CDropCommand::FreeRedoState(Environment* ev) // Override
- {
- fDroppedContent->DeleteSavedProxies(ev);
- }
-
- //========================================================================================
- // CInsertCommand
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CInsertCommand constructor
- //----------------------------------------------------------------------------------------
-
- CInsertCommand::CInsertCommand(Environment* ev,
- CContainerFrame* frame,
- const FW_PFileSpecification& fileSpec,
- CContainerSelection* selection,
- FW_Boolean canUndo) :
- FW_CInsertCommand(ev, frame, fileSpec, canUndo),
- fUndoContent(NULL),
- fContainerSelection(selection)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CInsertCommand destructor
- //----------------------------------------------------------------------------------------
-
- CInsertCommand::~CInsertCommand()
- {
- delete fUndoContent;
- }
-
- //----------------------------------------------------------------------------------------
- // CInsertCommand::PreCommand
- //----------------------------------------------------------------------------------------
-
- void CInsertCommand::PreCommand(Environment* ev)
- {
- fContainerSelection->CloseSelection(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CInsertCommand::CommandDone
- //----------------------------------------------------------------------------------------
-
- void CInsertCommand::CommandDone(Environment* ev)
- {
- fContainerSelection->CenterSelection(ev, GetFrame(ev));
- }
-
- //----------------------------------------------------------------------------------------
- // CInsertCommand::SaveRedoState
- //----------------------------------------------------------------------------------------
-
- void CInsertCommand::SaveRedoState(Environment* ev)
- {
- FW_ASSERT(fUndoContent == NULL);
- fUndoContent = FW_NEW(CUndoContent, (ev, fContainerSelection));
- }
-
- //----------------------------------------------------------------------------------------
- // CInsertCommand::FreeRedoState
- //----------------------------------------------------------------------------------------
-
- void CInsertCommand::FreeRedoState(Environment* ev)
- {
- fUndoContent->DeleteSavedProxies(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CInsertCommand::UndoIt
- //----------------------------------------------------------------------------------------
-
- void CInsertCommand::UndoIt(Environment* ev)
- {
- FW_CInsertCommand::UndoIt(ev);
- fUndoContent->RemoveProxySelection(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CInsertCommand::RedoIt
- //----------------------------------------------------------------------------------------
-
- void CInsertCommand::RedoIt(Environment* ev)
- {
- FW_CInsertCommand::RedoIt(ev);
- fUndoContent->RestoreProxySelection(ev);
- }
-
- //========================================================================================
- // CResizeCommand
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CResizeCommand constructor
- //----------------------------------------------------------------------------------------
- CResizeCommand::CResizeCommand(Environment* ev,
- CContainerPart* part,
- FW_CFrame* frame,
- CContainerSelection* selection,
- const FW_CRect& srcRect,
- const FW_CRect& dstRect)
- : FW_CCommand(ev, cResizeCommand, frame, FW_kCanUndo),
- fContainerPart(part),
- fContainerSelection(selection),
- fSourceRect(srcRect),
- fDestRect(dstRect),
- fUpdateShape(NULL),
- fChangedContent(NULL)
- {
- SetMenuStringsFromResource(ev, kUndoStrings, kUndoResizeMsg, kRedoResizeMsg);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CResizeCommand destructor
- //----------------------------------------------------------------------------------------
- CResizeCommand::~CResizeCommand()
- {
- FW_START_DESTRUCTOR
- delete fChangedContent;
-
- if (fUpdateShape)
- {
- FW_SOMEnvironment ev;
- fUpdateShape->Release(ev);
- }
- fUpdateShape = NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // CResizeCommand::DoIt
- //----------------------------------------------------------------------------------------
- void CResizeCommand::DoIt(Environment* ev) // Override
- {
- // Copy selected proxy pointers to our content object
- FW_ASSERT(fChangedContent == NULL);
- fChangedContent = FW_NEW(CBaseContent, (ev, fContainerSelection->GetSelectionContent(ev)));
-
- FW_ASSERT(fUpdateShape == NULL);
- fUpdateShape = fChangedContent->CalcUpdateShape(ev);
-
- this->ResizeProxies(ev, fSourceRect, fDestRect);
-
- {
- FW_CAcquiredODShape tempShape = fChangedContent->CalcUpdateShape(ev);
- fUpdateShape->Union(ev, tempShape);
- }
-
- this->Redraw(ev, kODDone);
- }
-
- //----------------------------------------------------------------------------------------
- // CResizeCommand::UndoIt
- //----------------------------------------------------------------------------------------
- void CResizeCommand::UndoIt(Environment* ev) // Override
- {
- this->ResizeProxies(ev, fDestRect, fSourceRect);
- this->Redraw(ev, kODUndone);
- }
-
- //----------------------------------------------------------------------------------------
- // CResizeCommand::RedoIt
- //----------------------------------------------------------------------------------------
- void CResizeCommand::RedoIt(Environment* ev) // Override
- {
- this->ResizeProxies(ev, fSourceRect, fDestRect);
- this->Redraw(ev, kODRedone);
- }
-
- //----------------------------------------------------------------------------------------
- // CResizeCommand::ResizeProxies
- //----------------------------------------------------------------------------------------
- void CResizeCommand::ResizeProxies(Environment* ev, const FW_CRect& srcRect, const FW_CRect& dstRect)
- {
- //--- Resize each proxy ---
- CContentProxyIterator it(fChangedContent);
- for (CProxy* proxy = it.First(); it.IsNotComplete(); proxy = it.Next())
- {
- proxy->ResizeProxy(ev, srcRect, dstRect);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CResizeCommand::Redraw
- //----------------------------------------------------------------------------------------
- void CResizeCommand::Redraw(Environment* ev, ODDoneState doneState)
- {
- FW_UNUSED(doneState);
- FW_CPresentation* presentation = fContainerPart->GetMainPresentation();
- presentation->Invalidate(ev, fUpdateShape);
-
- FW_CFacetClipper facetClipper;
- facetClipper.Clip(ev, presentation, fUpdateShape);
-
- // Select the resized proxies
- fContainerSelection->SelectContent(ev, fChangedContent);
- fContainerSelection->SelectionChanged(ev); // Notify everybody
- }
-
- //========================================================================================
- // CViewAsCommand
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CViewAsCommand constructor
- //----------------------------------------------------------------------------------------
- CViewAsCommand::CViewAsCommand(Environment* ev,
- CContainerPart* part,
- FW_CFrame* frame,
- CContainerSelection* selection,
- ODTypeToken newViewAs)
- : FW_CCommand(ev, cViewAsCommand, frame, FW_kCanUndo),
- fContainerPart(part),
- fContainerSelection(selection),
- fNewViewAs(newViewAs),
- fOldViewAs(NULL),
- fChangedContent(NULL),
- fUpdateShape(NULL)
- {
- SetMenuStringsFromResource(ev, kUndoStrings, kUndoEmbedAsMsg, kRedoEmbedAsMsg);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CViewAsCommand destructor
- //----------------------------------------------------------------------------------------
-
- CViewAsCommand::~CViewAsCommand()
- {
- FW_START_DESTRUCTOR
-
- if (fOldViewAs)
- FW_CMemoryManager::FreeBlock(fOldViewAs);
-
- delete fChangedContent;
-
- if (fUpdateShape)
- {
- FW_SOMEnvironment ev;
- fUpdateShape->Release(ev);
- }
- fUpdateShape = NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // CViewAsCommand::DoIt
- //----------------------------------------------------------------------------------------
-
- void CViewAsCommand::DoIt(Environment* ev) // Override
- {
- // Copy selected proxy pointers to our content object
- FW_ASSERT(fChangedContent == NULL);
- fChangedContent = FW_NEW(CBaseContent, (ev, fContainerSelection->GetSelectionContent(ev)));
-
- fOldViewAs = (ODTypeToken*)FW_CMemoryManager::AllocateBlock(fContainerSelection->Count() * sizeof(ODTypeToken));
-
- short n = 0;
- CContentProxyIterator it(fChangedContent);
- for (CProxy* proxy = it.First(); it.IsNotComplete(); proxy = it.Next())
- {
- fOldViewAs[n] = proxy->GetViewAs();
- n++;
- }
-
- FW_ASSERT(fUpdateShape == NULL);
- fUpdateShape = fChangedContent->CalcUpdateShape(ev);
-
- this->ChangeEmbeddedViewAs(ev, FALSE);
-
- {
- FW_CAcquiredODShape tempShape = fChangedContent->CalcUpdateShape(ev);
- fUpdateShape->Union(ev, tempShape);
- }
-
- this->Redraw(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CViewAsCommand::UndoIt
- //----------------------------------------------------------------------------------------
-
- void CViewAsCommand::UndoIt(Environment* ev) // Override
- {
- this->ChangeEmbeddedViewAs(ev, TRUE);
- this->Redraw(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CViewAsCommand::RedoIt
- //----------------------------------------------------------------------------------------
-
- void CViewAsCommand::RedoIt(Environment* ev) // Override
- {
- this->ChangeEmbeddedViewAs(ev, FALSE);
- this->Redraw(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CViewAsCommand::ChangeEmbeddedViewAs
- //----------------------------------------------------------------------------------------
-
- void CViewAsCommand::ChangeEmbeddedViewAs(Environment* ev, FW_Boolean undo)
- {
- short n = 0;
- //--- Resize each proxy ---
- CContentProxyIterator it(fChangedContent);
- for (CProxy* proxy = it.First(); it.IsNotComplete(); proxy = it.Next())
- {
- proxy->ChangeViewAs(ev, undo ? fOldViewAs[n] : fNewViewAs);
- n++;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CViewAsCommand::Redraw
- //----------------------------------------------------------------------------------------
-
- void CViewAsCommand::Redraw(Environment* ev)
- {
- FW_CPresentation* presentation = fContainerPart->GetMainPresentation();
- presentation->Invalidate(ev, fUpdateShape);
-
- FW_CFacetClipper facetClipper;
- facetClipper.Clip(ev, presentation, fUpdateShape);
-
- // Select the resized proxies
- fContainerSelection->SelectContent(ev, fChangedContent);
- fContainerSelection->SelectionChanged(ev); // Notify everybody
- }
-
- //========================================================================================
- // class CSetBackgroundColorCommand
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CSetBackgroundColorCommand::CSetBackgroundColorCommand
- //----------------------------------------------------------------------------------------
-
- CSetBackgroundColorCommand::CSetBackgroundColorCommand(Environment* ev,
- CContainerPart* part,
- FW_CColor& newBackgroundColor) :
- FW_CCommand(ev, cSetBackgroundColor, part->GetLastActiveFrame(ev), TRUE),
- fContainerPart(part),
- fOldColor(),
- fNewColor(newBackgroundColor)
- {
- fOldColor = fContainerPart->GetBackgroundColor();
- SetMenuStringsFromResource(ev, kUndoStrings, kUndoSetBackColorMsg, kRedoSetBackColorMsg);
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CSetBackgroundColorCommand::~CSetBackgroundColorCommand
- //----------------------------------------------------------------------------------------
-
- CSetBackgroundColorCommand::~CSetBackgroundColorCommand()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CSetBackgroundColorCommand::DoIt
- //----------------------------------------------------------------------------------------
-
- void CSetBackgroundColorCommand::DoIt(Environment* ev)
- {
- fContainerPart->SetBackgroundColor(ev, fNewColor);
- }
-
- //----------------------------------------------------------------------------------------
- // CSetBackgroundColorCommand::UndoIt
- //----------------------------------------------------------------------------------------
-
- void CSetBackgroundColorCommand::UndoIt(Environment* ev)
- {
- fContainerPart->SetBackgroundColor(ev, fOldColor);
- }
-
- //----------------------------------------------------------------------------------------
- // CSetBackgroundColorCommand::RedoIt
- //----------------------------------------------------------------------------------------
-
- void CSetBackgroundColorCommand::RedoIt(Environment* ev)
- {
- fContainerPart->SetBackgroundColor(ev, fNewColor);
- }
-